package demo5;

class OutClass{
    //静态内部类
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;
    static class InnerClass{
        public int data4 =4;
        private int data5 = 5;
        public static int data6 = 6;
        public void test(){
            OutClass outClass = new OutClass();
            //System.out.println(data1);static不能直接访问别的类中的成员变量
            System.out.println(outClass.data1);
            System.out.println(data4);
            System.out.println(data3);
            System.out.println(data5);
            System.out.println(data6);
        }
    }
}

class OutClass2{
    //实例内部类
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;
    class InnerClass2{
        public int data1 = 100;
        public int data4 =4;
        private int data5 = 5;
        public static int data6 = 6;
        public void test(){
            OutClass2 outClass = new OutClass2();
            System.out.println(outClass.data1);
            System.out.println(OutClass2.this.data1);
            System.out.println(this.data1);
            System.out.println(data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }
}

class a{
    void test(){
        System.out.println("xx");
    }
}
interface IA{
    void test1();
}
public class Test {
    public static void main(String[] args) {
        IA a = new IA() {
            @Override
            public void test1() {
                System.out.println("xxxxxxxxx");
            }
        };
        a.test1();


        new a(){
            @Override
            void test() {
                System.out.println("xxxxx");
            }
        }.test();
    }
    public void testMethod(){
        //局部内部类
        class Inner{
            public int data;
            public void func(){
                System.out.println("func");
            }

        }
        Inner inner = new Inner();
        inner.func();
    }
    public static void main2(String[] args) {
        OutClass2 outClass2 = new OutClass2();
        OutClass2.InnerClass2 innerClass = outClass2.new InnerClass2();
        innerClass.test();
    }
    public static void main1(String[] args) {
        OutClass.InnerClass innerClass = new OutClass.InnerClass();
        innerClass.test();
    }
}
